/*
  Part of the MasterTool3D project - http://code.google.com/p/master-tool-3d

  Copyright (c) 2011 Ingo Pueschl

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation, version 2.1.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General
  Public License along with this library; if not, write to the
  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  Boston, MA  02111-1307  USA
*/

package techjit.api.handlers.keyboardactionhandler;

import java.awt.Toolkit;

import techjit.api.handlers.SceneRecursionHandler;
import techjit.gfx.core.GFX_Scene;
import techjit.gfx.util.PU;

public abstract class KeyboardActionManager {

	static void chooseByMousePosition() {
		GFX_Scene scene = KeyboardActionHandler.scene;
		scene.changeCurrentSceneElement_chooseByMousePosition();
	}

	static void chooseFirstChild() {
		GFX_Scene scene = KeyboardActionHandler.scene;
		if (!scene.navi_chooseFirstChild()) {
			Toolkit.getDefaultToolkit().beep();
		}
	}

	static void chooseFirstSibling() {
		GFX_Scene scene = KeyboardActionHandler.scene;
		if (!scene.navi_chooseFirstSibling()) {
			Toolkit.getDefaultToolkit().beep();
		}
	}

	static void chooseLastSibling() {
		GFX_Scene scene = KeyboardActionHandler.scene;
		if (!scene.navi_chooseLastSibling()) {
			Toolkit.getDefaultToolkit().beep();
		}
	}

	static void chooseNextSibling() {
		GFX_Scene scene = KeyboardActionHandler.scene;
		if (!scene.navi_chooseNextSibling()) {
			Toolkit.getDefaultToolkit().beep();
		}
	}

	static void chooseParent() {
		GFX_Scene scene = KeyboardActionHandler.scene;
		if (!scene.navi_chooseParent()) {
			Toolkit.getDefaultToolkit().beep();
		}
	}

	static void choosePreviousSibling() {
		GFX_Scene scene = KeyboardActionHandler.scene;
		if (!scene.navi_choosePreviousSibling()) {
			Toolkit.getDefaultToolkit().beep();
		}
	}

	static void chooseTop() {
		GFX_Scene scene = KeyboardActionHandler.scene;
		if (!scene.navi_chooseTop()) {
			Toolkit.getDefaultToolkit().beep();
		}
	}

	static void rotateCurrentX() {
		GFX_Scene scene = KeyboardActionHandler.scene;
		scene.currentSceneElement.rotationMatrix.preApply(PU
				.getRotationMatrixX(5));
		SceneRecursionHandler.arrange(scene);
	}

	static void rotateCurrentY() {
		GFX_Scene scene = KeyboardActionHandler.scene;
		scene.currentSceneElement.rotationMatrix.preApply(PU
				.getRotationMatrixY(5));
		SceneRecursionHandler.arrange(scene);
	}

	static void rotateCurrentZ() {
		GFX_Scene scene = KeyboardActionHandler.scene;
		scene.currentSceneElement.rotationMatrix.preApply(PU
				.getRotationMatrixZ(5));
		SceneRecursionHandler.arrange(scene);
	}

	static void rotateInverseCurrentX() {
		GFX_Scene scene = KeyboardActionHandler.scene;
		scene.currentSceneElement.rotationMatrix.preApply(PU
				.getRotationMatrixX(-5));
		SceneRecursionHandler.arrange(scene);
	}

	static void rotateInverseCurrentY() {
		GFX_Scene scene = KeyboardActionHandler.scene;
		scene.currentSceneElement.rotationMatrix.preApply(PU
				.getRotationMatrixY(-5));
		SceneRecursionHandler.arrange(scene);

	}

	static void rotateInverseCurrentZ() {
		GFX_Scene scene = KeyboardActionHandler.scene;
		scene.currentSceneElement.rotationMatrix.preApply(PU
				.getRotationMatrixZ(-5));

		SceneRecursionHandler.arrange(scene);
	}

}
